SCRIPT=$(readlink -f $0)
WD=`dirname $SCRIPT`
ROOT_DIR=${WD}/opencv-4.10.0

BUILD_DIR=${ROOT_DIR}/build_x86_64_linux
INSTALL_DIR=${WD}/x86_64_linux_opencv-4.10.0

rm -rf "${BUILD_DIR}"
mkdir -p "${BUILD_DIR}"
cd "${BUILD_DIR}"

cmake -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
      -D WITH_CUDA=OFF \
      -D WITH_MATLAB=OFF \
      -D BUILD_DOCS=OFF \
      -D BUILD_PERF_TESTS=OFF \
      -D BUILD_TESTS=OFF \
      -D WITH_PROTOBUF=OFF \
      -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
      ..

make -j8
make install